import { reqAddressList, reqShopOrderList } from '@/api'
const namespaced = true

const state = {
  addressListInfo: [],
  shopOederList : {}
}

const actions = {
  // 获取地址
  async getAddressList({ commit }) {
    let result = await reqAddressList()
    if (result.code === 200) {
      commit('GETADDRESSLIST', result.data)
      return 'ok'
    }else {
      return Promise.reject(new Error('err'))
    }
  },
  // 获取商品
  async getShopOrderList({commit}){
    let result = await reqShopOrderList()
    if (result.code === 200) {
      commit('GETSHOPORDERLIST', result.data)
      return 'ok'
    }else {
      return Promise.reject(new Error('err'))
    }
  }
}

const mutations = {
  GETADDRESSLIST(state, info){
    state.addressListInfo = info
  },
  GETSHOPORDERLIST(state, info){
    state.shopOederList = info
  }
}

const getters = {}

export default {
  namespaced,
  state,
  actions,
  mutations,
  getters
}